package com.jzk.cloudshop.weixin.web;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConfig;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api("微信支付接口")
@RestController
@RequestMapping("/pay/weixin")
@ComponentScan(value = "com.github.wxpay.sdk.*")
class PayWeixinServiceController {

	protected static final Logger logger = LoggerFactory.getLogger(PayWeixinServiceController.class);

	@Autowired
	private WXPayConfig wxPayConfig;
	
	@ApiOperation(value = "生成支付二维码", notes = "")
	@RequestMapping(value = { "/createPrepayQRCode" }, method = RequestMethod.GET)
	public Map<String, String> createPrepayQRCode() {
		try {
			WXPay wxPay = new WXPay(wxPayConfig);
			Map<String, String> reqData = new HashMap<>();
			//设置订单信息
			reqData.put("", "");
			Map<String, String> responseMap = wxPay.unifiedOrder(reqData);
			return responseMap;
		} catch (Exception e) {
			logger.error(e.getLocalizedMessage(), e);
		}
		return null;
	}
	
	//支付回调
	public void callback() {
		
	}
}